home *** CD-ROM | disk | FTP | other *** search
- // Tab control
-
-
- // -------------------------------------------------------------
- // Constructors
- // -------------------------------------------------------------
- func Gui_Component NewTabControl();
- // Message
- message BackgroundTab(i32x _iTabId);
- message ShowTab(i32x _iTabId);
- message ShowTabOver(i32x _iTabId);
- message HideTab();
- message NextTab();
- message PreviousTab();
- message AddTab(Gui_Component _poTab);
- message SetOnBackground(i32x _iTabId);
- message SetOnForeground();
- message ToggleOk();
- // -------------------------------------------------------------
- // -------------------------------------------------------------
-
-
-
- // Data class
- class Gui_dtTabControl
- {
- var i32x iBackgroundId; // Current displayed background tab Id
- var i32x iTabId; // Current displayed tab Id
- var i32x iNumTab; // Tab number
- };
-
- // forward declaration
-
- func void TabControl_ShowTab(i32x _iTabId);
- func void TabControl_ShowTabOver(i32x _iTabId);
- func void TabControl_HideTab();
- func void TabControl_ToggleOk();
- func void TabControl_NextTab();
- func void TabControl_PreviousTab();
- func void TabControl_BackgroundTab(i32x _iTabId);
- func void TabControl_AddTab(Gui_Component _poTab);
- func void TabControl_WindowUpdate();
-
- // Message handling interface
- interface Gui_iTabControl
- {
- TabControl_ShowTab ShowTab;
- TabControl_ShowTabOver ShowTabOver;
- TabControl_NextTab NextTab;
- TabControl_PreviousTab PreviousTab;
- TabControl_AddTab AddTab;
- TabControl_HideTab HideTab;
- TabControl_BackgroundTab BackgroundTab;
- TabControl_ToggleOk ToggleOk;
- TabControl_WindowUpdate WindowUpdate;
- }
-
- func Gui_Component NewTabControl()
- {
- var Gui_Component ptabcontrol;
- var Gui_dtTabControl pdtTabcontrol;
-
- // Create table object
- ptabcontrol = NewObject(Gui_iTabControl);
- pdtTabcontrol = new Gui_dtTabControl;
- SetData(ptabcontrol,pdtTabcontrol);
-
- // Fill data
- pdtTabcontrol.iNumTab = 0;
- pdtTabcontrol.iTabId = -1;
- pdtTabcontrol.iBackgroundId = -1;
-
- // Stretch tab control
- // Clip(ptabcontrol);
- Transparent(ptabcontrol);
-
- return ptabcontrol;
- }
-
- func void TabControl_ToggleOk()
- {
- var Gui_Component ptabcontrol,ptab,pparent;
- var Gui_dtTabControl pdtTab;
- var i32x iWidth,iHeight;
-
- // Retrieve table pointer
- ptabcontrol = GetThis();
-
- // Retrieve data pointer
- pdtTab = GetData(ptabcontrol);
- ptab = GetComponent(ptabcontrol,pdtTab.iTabId);
- if(ptab)
- {
- iWidth = SizeX(ptab);
- iHeight = SizeY(ptab);
-
- // Show table
- ptab<<Show();
-
- // Make appear in foreground
- GoToForeground(ptabcontrol,pdtTab.iTabId);
-
- // Stretch tab control to fit content
- StretchTo(ptabcontrol,iWidth,iHeight);
-
- // Send window content update
- pparent = GetParent(ptabcontrol);
- if(pparent)
- pparent<<WindowUpdate();
- }
- }
-
- func void TabControl_ShowTabOver(i32x _iTabId)
- {
- var Gui_Component ptabcontrol,ptab,pparent;
- var Gui_dtTabControl pdtTab;
- var i32x iWidth,iHeight;
-
- // Retrieve table pointer
- ptabcontrol = GetThis();
-
- // Retrieve data pointer
- pdtTab = GetData(ptabcontrol);
-
- ptab = GetComponent(ptabcontrol,_iTabId);
- if(ptab)
- {
- iWidth = SizeX(ptab);
- iHeight = SizeY(ptab);
- // Display new table over the other
- ptab<<Show();
-
- // Make appear in foreground
- GoToForeground(ptabcontrol,_iTabId);
-
- // Stretch tab control to fit content
- StretchTo(ptabcontrol,iWidth,iHeight);
- // Send window content update
- pparent = GetParent(ptabcontrol);
-
- if(pparent)
- pparent<<WindowUpdate();
- }
- }
-
- func void TabControl_WindowUpdate()
- {
- var Gui_Component ptabcontrol,ptab,pparent;
- var Gui_dtTabControl pdtTab;
- var i32x iWidth,iHeight;
-
- // Retrieve table pointer
- ptabcontrol = GetThis();
-
- // Retrieve data pointer
- pdtTab = GetData(ptabcontrol);
- ptab = GetComponent(ptabcontrol,pdtTab.iTabId);
-
- if(ptab)
- {
- iWidth = SizeX(ptab);
- iHeight = SizeY(ptab);
-
- //println("TabControlWindowUpdate");
- //println(itoa(iWidth));
- //println(itoa(iHeight));
-
- // Stretch tab control to fit content
- StretchTo(ptabcontrol,iWidth,iHeight);
- // Send window content update
- pparent = GetParent(ptabcontrol);
- if(pparent)
- pparent<<WindowUpdate();
- }
- }
-
- func void TabControl_ShowTab(i32x _iTabId)
- {
- var Gui_Component ptabcontrol,ptab,pparent;
- var Gui_dtTabControl pdtTab;
- var i32x iWidth,iHeight;
- var boolx bWaitForToggle;
-
- bWaitForToggle = false;
- // Retrieve table pointer
- ptabcontrol = GetThis();
-
- // Retrieve data pointer
- pdtTab = GetData(ptabcontrol);
-
- if(_iTabId != pdtTab.iTabId)
- {
- // Switch tab
- if(pdtTab.iTabId != -1)
- {
- ptab = GetComponent(ptabcontrol,pdtTab.iTabId);
- if(ptab)
- {
- if(pdtTab.iTabId != pdtTab.iBackgroundId)
- {
- ptab<<Hide();
- }
- else
- {
- bWaitForToggle = true;
- }
- // Inform go back
- //ptab<<Disable();
- ptab<<SetOnBackground(_iTabId);
- }
- }
- pdtTab.iTabId = _iTabId;
- if(bWaitForToggle == false)
- {
- ptab = GetComponent(ptabcontrol,pdtTab.iTabId);
- if(ptab)
- {
- iWidth = SizeX(ptab);
- iHeight = SizeY(ptab);
- // Display new table
- if(pdtTab.iTabId != pdtTab.iBackgroundId)
- {
- ptab<<Show();
- }
- // Inform go to foreground
- //ptab<<Enable();
- ptab<<SetOnForeground();
-
- // Make appear in foreground
- GoToForeground(ptabcontrol,pdtTab.iTabId);
-
- // Stretch tab control to fit content
- StretchTo(ptabcontrol,iWidth,iHeight);
- // Send window content update
- pparent = GetParent(ptabcontrol);
- if(pparent)
- pparent<<WindowUpdate();
- }
- }
- }
- }
-
- func void TabControl_BackgroundTab(i32x _iTabId)
- {
- var Gui_Component ptabcontrol,ptab;
- var Gui_dtTabControl pdtTab;
-
- // Retrieve table pointer
- ptabcontrol = GetThis();
-
- // Retrieve data pointer
- pdtTab = GetData(ptabcontrol);
-
- if(pdtTab.iBackgroundId != -1)
- {
- // Switch tab
- ptab = GetComponent(ptabcontrol,pdtTab.iBackgroundId);
- if(ptab)
- {
- ptab<<Hide();
- }
- }
-
- if(pdtTab.iBackgroundId != _iTabId)
- {
- pdtTab.iBackgroundId = _iTabId;
-
- if(_iTabId!=-1)
- {
- ptab = GetComponent(ptabcontrol,pdtTab.iBackgroundId);
- if(ptab)
- {
- ptab<<Show();
- }
- }
- }
- }
-
- func void TabControl_HideTab()
- {
- var Gui_Component ptabcontrol,ptab,pparent;
- var Gui_dtTabControl pdtTab;
- var i32x iWidth,iHeight;
-
- // Retrieve table pointer
- ptabcontrol = GetThis();
-
- // Retrieve data pointer
- pdtTab = GetData(ptabcontrol);
-
- // Switch tab
- ptab = GetComponent(ptabcontrol,pdtTab.iTabId);
- if(ptab)
- {
- ptab<<Hide();
- }
- pdtTab.iTabId = -1;
-
- // Send window content update
- pparent = GetParent(ptabcontrol);
- if(pparent)
- pparent<<WindowUpdate();
- }
-
- func void TabControl_NextTab()
- {
- var Gui_Component ptabcontrol;
- var Gui_dtTabControl pdtTab;
-
- // Retrieve table pointer
- ptabcontrol = GetThis();
-
- // Retrieve data pointer
- pdtTab = GetData(ptabcontrol);
-
- if(pdtTab.iTabId < pdtTab.iNumTab)
- {
- TabControl_ShowTab(pdtTab.iTabId+1);
- }
- }
- func void TabControl_PreviousTab()
- {
- var Gui_Component ptabcontrol,ptab;
- var Gui_dtTabControl pdtTab;
-
- // Retrieve table pointer
- ptabcontrol = GetThis();
-
- // Retrieve data pointer
- pdtTab = GetData(ptabcontrol);
-
- if(pdtTab.iTabId > 0)
- {
- TabControl_ShowTab(pdtTab.iTabId-1);
- }
- }
- func void TabControl_AddTab(Gui_Component _poTab)
- {
- var Gui_Component ptab;
- var Gui_dtTabControl pdtTab;
-
- // Retrieve table pointer
- ptab = GetThis();
-
- // Retrieve data pointer
- pdtTab = GetData(ptab);
-
- // Mount tab on tabcontrol
- MountComponent(ptab,_poTab);
-
- // Increment tab number
- pdtTab.iNumTab = pdtTab.iNumTab + 1;
-
- // Hide added tab
- _poTab<<Hide();
- }
-